package Demo9;

import java.util.concurrent.ArrayBlockingQueue;

public class Producer extends Thread{
    private ArrayBlockingQueue<String> queue;

    public Producer(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }
    @Override
    public void run() {
        while (true) {
            try {
                queue.put("物品"+ThreadDemo.count);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("生产者生产了一件物品"+ThreadDemo.count++);

        }
    }
}
